package com.example.diagnose.Service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.diagnose.Domain.User;
import com.example.diagnose.Mapper.UserMapper;
import com.example.diagnose.Service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private User user;

    @Resource
    private UserMapper userMapper;

    @Override
    public int addUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateById(user);
    }

    @Override
    public User getUserByTel(String tel) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("tel", tel);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public User getUserByAccount(String account) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("account", account);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public List<User> getUser() {
        return userMapper.selectList(null);
    }
}
